﻿CREATE TABLE [dbo].[UndoEntityRelationships] (
    [UndoEntityRelationshipsID] INT           IDENTITY (1, 1) NOT NULL,
    [ShortRelationshipName]     NVARCHAR (12) NOT NULL,
    [Entity1ID]                 INT           NOT NULL,
    [Entity2ID]                 INT           NOT NULL,
    [OldStartDate]              DATETIME      NULL,
    [NewStartDate]              DATETIME      NULL,
    [OldEndDate]                DATETIME      NULL,
    [NewEndDate]                DATETIME      NULL,
    [UndoAction]                NVARCHAR (10) NOT NULL,
    [ChangedBy]                 INT           NOT NULL,
    [WhenChanged]               DATETIME      NOT NULL,
    CONSTRAINT [PK_UndoEntityRelationships] PRIMARY KEY CLUSTERED ([UndoEntityRelationshipsID] ASC),
    CONSTRAINT [FK_UndoEntityRelationships_DefinedUndoActions] FOREIGN KEY ([UndoAction]) REFERENCES [dbo].[DefinedUndoActions] ([UndoAction]),
    CONSTRAINT [FK_UndoEntityRelationships_Entities2] FOREIGN KEY ([ChangedBy]) REFERENCES [dbo].[Entities] ([EntityID])
);

